{% extends "blog/base.html" %}
{% load blog_tags %}

{% block title %}{{ post.title }}{% endblock %}

{% block content %}
    <h1>{{ post.title }}</h1>
    {{ post.body|markdown }}
    <p class="date">
        作者：{{ post.author }}  发布时间：{{ post.publish }}
    </p>
    <p>
        <a href="{% url "blog:post_share" post.id %}">分享</a>
    </p>
    <p>类似发布：</p>
    {% for post in similar_posts %}
        <p>
            <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
        </p>
    {% empty %}
        无类似
    {% endfor %}

    {% with comments.count as total_comments %}
    <p>{{ total_comments }} 评论</p>
    {% endwith %}
    {% for comment in comments %}
        <div class="comment">
            {{ comment.body }}
            <p class="date">作者：{{ comment.name }}  发布时间：{{ comment.created }}</p>
        </div>
    {% empty %}
        <p>啥说法也没有</p>
    {% endfor %}

    {% if new_comment %}
        <p>已添加</p>
    {% else %}
        <p>添加评论</p>
        <form action="." method="post">
            {% csrf_token %}
            {% for f in comment_form %}
                <div>
                    <label for="id_{{ f.name }}">{{ f.name }}</label>
                    <input id="id_{{ f.name }}" type="text" name="{{ f.name }}" maxlength="100" required>
                </div>
            {%endfor %}
            <p><input type="submit" value="添加"></p>
        </form>
    {% endif %}
{% endblock %}